/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Request;

import Request.RequestType;
import java.io.*;
import java.util.*;
import java.net.*;

import AccManager.UserProfile;
import Common.InfoLogger;
/**
 *
 * @author lcy
 */

public abstract class Request implements Serializable{

    /* Public properties*/
    protected InetAddress _local_ip_addr;

    protected int _local_port;

    protected RequestType _request_type;

    /* Private data */
    private InfoLogger _debugger;

    public Request(){
        _request_type = RequestType.LOGIN;
        InitCommComponents();
    }

    public Request(RequestType r_type){
        _request_type = r_type;
        InitCommComponents();
    }

    public Request(Request request){
        _request_type = request.GetRequestType();
        InitCommComponents();
    }

    private void InitCommComponents(){
        _local_ip_addr = null;
        _local_port = -1;
        _debugger = new InfoLogger();
    }

    public RequestType GetRequestType(){
        return _request_type;
    }

    public void SetRequestType(RequestType type){
        _request_type = type;
    }

    //Different requests have different request content
    public abstract Object GetRequestContent();

    public InetAddress GetLocalInetAddress(){

        return _local_ip_addr;
    }

    public void SetLocalInetAddr(InetAddress addr){
          _local_ip_addr = addr;
    }

    public void SetLocalPort(int port){
        _local_port = port;
    }

    public int GetLocalPort(){
        return _local_port;
    }
}
